package com.zang.dp;

/**
 * @author ZVerify
 * @since 2022/11/23 23:09
 * @see <a href="https://leetcode.cn/problems/fibonacci-number/description/">...</a>
 **/
public class 斐波那契数 {

    public int fib(int n) {
        if (n<2) return n;

        int[] nums = new int[n+1];
        nums[0] = 0;
        nums[1] = 1;
        int i = 2;
        while (i<=n) {
            nums[i] = nums[i-1]+ nums[i-2];
            i++;
        }
        return nums[n];
    }
}
